<h4>Add Track by External URL</h4>
<form id="add-track-by-url">

    <label for="add-track-by-url-url">URL:</label><br />
    <input type="text" id="add-track-by-url-url"
           style="width: 99%;"/>

    <label for="add-track-by-url-kind">Kind:</label><br />
    <select id="add-track-by-url-kind">
        <?php foreach ($kinds as $kind): ?>
            <option value='<?php echo $kind ?>'><?php echo $kind ?></option>
        <?php endforeach; ?>
    </select><br />

    <label for="add-track-by-url-srclang">Srclang:</label><br />
    <input type="text" id="add-track-by-url-srclang" /><br />

    <label for="add-track-by-url-label">Label:</label><br />
    <input type="text" id="add-track-by-url-label"
           style="width: 99%;"/>

    <p style="float: right;">
        <input type="submit"
               value="Submit Track" />
    </p>
    <div class="clear" ></div>
</form>

<script type="text/javascript">
    var av_current_count;
    var html5av_api = '<?php echo html5av_manager::getApiURL() ?>';
    
    function html5avTrackExternalPanelCheck() {
        var src = jQuery('#add-track-by-url-url').val();
        var srclang = jQuery('#add-track-by-url-srclang').val();
        var label = jQuery('#add-track-by-url-label').val();
        var noError = true;
        var msg = '';
        if(src == '') {
            noError = false;
            msg += "URL cannot be left blank\n";
        }
        
        if(srclang == '') {
            noError = false;
            msg += "Srclang cannot be left blank\n";
        }
        
        if(label == '') {
            noError = false;
            msg += "Label cannot be left blank\n";
        }
        
        if(!noError) {
            alert(msg);
        }
        
        return noError;
    }
    
    jQuery(function($) {
        $('#add-track-by-url').submit(function() {
            if(html5avTrackExternalPanelCheck()) {
                var src = $('#add-track-by-url-url').val();
                var kind = $('#add-track-by-url-kind').val();
                var srclang = $('#add-track-by-url-srclang').val();
                var label = $('#add-track-by-url-label').val();
                var post = {
                    action: 'html5av_manager',
                    node:'track_external_submit',
                    avid:av_edit_id,
                    src:src,
                    kind:kind,
                    srclang:srclang,
                    label:label
                };
                $.post(ajaxurl, post, function() {
                    html5avReset();
                });
            }
            return false;
        });
    });
</script>